<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="DBController.*" %>
<%@ page import="java.util.List" %>
<%@page import="java.util.ArrayList"%>
<%
//HttpSession hostsession = request.getSession(true);
//int hostFamilyID = Integer.parseInt(hostsession.getAttribute("hostFamilyID").toString());
DBConnector dbConn = DBConnector.getInstance();
List<DBController.room> roomList = dbConn.getAllRoom(1);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div id="getAllRoom">
<a href="../hosts/add-room.html">Add a new room</a><br><br>
<table border="1">
	<tr>
		<td>Name</td>
		<td>Type</td>
		<td>Size(m2)</td>
		<td>Facilities</td>
		<td>Price($/day)</td>
		<td>Room Images</td>
		<td>Action</td>
	</tr>
	<%for(DBController.room roomObj : roomList) {%>
	<tr>
		<td><%=roomObj.getRoomName()%></td>
		<td><%=roomObj.getRoomType()%></td>
		<td><%=roomObj.getRoomSize()%></td>
		<td>
			<label>Bathroom:<%if(roomObj.getHasInsideBathroom() == 'Y'){ %>Yes<%} else{%>No<%} %></label><br>
			<label>Television:<%if(roomObj.getHasInsideTV() == 'Y'){ %>Yes<%} else{%>No<%} %></label><br>
			<label>Air Condition:<%if(roomObj.getHasInsideAirCondition() == 'Y'){ %>Yes<%} else{%>No<%} %></label><br>
			<label>Fridge:<%if(roomObj.getHasInsideFridge() == 'Y'){ %>Yes<%} else{%>No<%} %></label>
		</td>
		<td><%=roomObj.getPricePerDay()%></td>
		<td>
		<%List<DBController.roomPhoto> roomPhotoList = dbConn.getRoomPhoto(roomObj.getRoomID());
		  for(DBController.roomPhoto roomPhotoObj : roomPhotoList){
		%>
		<img border="0" src="..<%=roomPhotoObj.getPhotoURL() %>" alt="Image" width="101" height="76">
		<%} %>
		</td>
		<td>
			<input type="button" id="Update" name="<%=roomObj.getRoomID() %>" value="Update"><br>
			<input type="button" id="Delete" name="<%=roomObj.getRoomID() %>" value="Delete">
		</td>
	</tr>
	<%} %>
</table>
</div>
</body>
</html>